Simulating a community of interacting individuals with social preferences

The basic concept consists of creating a network of known preferred partners within a community, then creating a process model in which actors move through a study site while balancing individual spatial and social preferences.


In this example, I start with a community of n=100 individuals and attempt to create a dolphin-like process model. The bolded parameters are the imput parameters that can be easily modified. The full R code can be found at https://github.com/vjf2/SimSociety.

First I assign preferences to 0.06% (n=296 edges) of all possible edges. The preference network is created by simulating a Holme-Kim random network, fastnet::net.holme.kim(), with maximum transitivity. I then manually modified the network to increase modularity while retaining a connected graph, for a final modularity value of Q=0.74. Individuals have on average 6 preferences each (range 3-15).
Preference network

Second, “core” home ranges are created for each individual to represent, for instance, preferred foraging grounds. To ensure some overlap between preferred pairs, I laid out the preference network using a Fruchterman-Reingold force-directed layout algorithm to minimize the relative starting distance between preferred pairs. The starting points were laid out on an approximately 100 x 100 grid with an average distance of 25 units between nodes. Each animal then takes a bounded random walk for d = 2000 steps, without leaving a maxDist = 10 radius of their starting location. This results in pairs that have on average about 7% overlap between their core home ranges.

Avoidances are then randomly sampled from the set of non-preferred pairs that have at least 10% overlap between their core UDs (n = 296 or 6% of pairs). These should likely also be assigned with some increased transitivity (i.e., shared avoidances), but that hasn’t been implemented yet. The rest of the pairs are set to associate randomly.

These actors with their individually-specific core ranges and sets of preferences and avoidances are then put through a simulation in which they tradeoff moving through their core ranges with grouping with other actors.

Individuals decide whom to group with by evaluating the costs of joining and maintaining each connection. Costs are proportional to distance for all types of pairs, but weighted differently for each category. Joining cost weights (jcw) are multiplied by the distance and maintenance costs are added (mc), such that cluster_distance = spatial_distance * jcw + mc. The cost to join a random partner is directly proportional to distance (jcw = 1), with a small cost for maintaining the relationship between time steps (mc = 1). The cost to join a preferred partner is proportionally less than the difference between pairs (jcw = 0.1) with no cost to maintenance (mc = 0). The cost to join an avoided partner is higher (jcw = 10) with a higher cost to maintenance (mc = 2).

At each time step, individuals decide whether to “forage” in their core home ranges or to join a group. All individuals forage independently on average once every 7 time steps, such that a minimum of 15% of the population is foraging alone at any given step. When individuals are foraging, they follow the same bounded random walk generated for them in the beginning of the simulation.

When individuals group, they are clustered into groups (via hierarchical clustering, stats::hclust()) using the weighted distance matrix. They are grouped into 20 clusters of varying sizes (range 1-15), resulting in an average group size of 2.8 (comparable to that reported in Galezo et al. 2018). Lone individuals stay in their core ranges. Individuals in groups move to a semi-centralized location based on their previous positions. Each group has a randomly selected “leader” and the group centroid is biased toward that leader’s core home range with some relative weight (leader weight = 2). Individuals can only move a maximum distance per day (dayDist = 20), and if their goal location is beyond that, they move halfway toward the goal location and re-evaluate at the next time step. The simulation proceeds for d = 2000 time steps.

A subset of 50 timesteps of the simulation

Once the simulation has finished, the resulting home range overlap and association indices can be compared for pairs in each category.

Simulation

The full simulation can then be subsampled in both time and space to generate a dataset to enter into the different null models.


Possible Future Directions

  1. Implement Sah et al. 2014 random modular graph algorithm in R to generate modular preference and avoidance networks
  2. Add attractive common features, these could be moving and transient (e.g., school of fish) or stationary and permanent (e.g., a segrass bed)
  3. Modify algorithm such that individuals don’t move to a common location to associate, but rather approach to within a set distance, or tolerate a set distance while actively moving away from other individuals (i.e., lizard-type model)
  4. Add demographic turnover with new individuals entering and leaving the study site.